<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>后台管理系统</title>
	<link rel="stylesheet" href="__WEBPUBLIC__/Admin/css/reset.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="__WEBPUBLIC__/Admin/css/style.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="__WEBPUBLIC__/Admin/css/invalid.css" type="text/css" media="screen" />
	<script type="text/javascript" src="__WEBPUBLIC__/Admin/js/jquery-1.9.1.min.js"></script>
    <link rel="stylesheet" href="__WEBPUBLIC__/Home/css/weui.min.css">
    <link rel="stylesheet" href="__WEBPUBLIC__/Home/css/top.css">

</head>
<body>
<div id="main-content">
	<div class="content-box">
		<!--头部切换-->
		<div class="content-box-header">
			<h3>举报列表</h3>
			<div class="clear"></div>
		</div>

		<div class="content-search" style="height: 40px;margin: 10px 0 0 10px;">
			<form action="{:U('Jubao/jubaolist')}" method="post">
				姓名：<input type="text" name="name" class="text-input" value="{$_REQUEST['name']}">
				举报时间：<input type="date" name="ctime" class="text-input" value="{$_REQUEST['ctime']}">
				状态：<select name="status" class="text-input">
					<option value=""></option>

					<option value="0" <if condition="$_REQUEST['status'] eq 0">checked</if>>待审核</option>
					<option value="1" <if condition="$_REQUEST['status'] eq 1">checked</if>>已发布</option>
					<option value="4" <if condition="$_REQUEST['status'] eq 4">checked</if>>已撤销</option>
				</select>
				<input type="submit" class="button search-btn" value="查询">
                <a class="button search-btn" href="{:U('Jubao/expJub')}">导出</a>

			</form>
		</div>


		<!--表格内容-->
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">
				<form action="{:U('AdminBasic/delList',array('tname'=>'Qcode','type'=>'real'))}" method="post">
					<table border="1">
						<!--标题-->
						<thead>
						<tr>
							<th width="5%">
								<!-- <input class="check-all" type="checkbox"/> -->
								ID
							</th>
							<th width="10%">姓名</th>
							<th width="20%">身份证</th>
							<th width="10%">电话</th>
							<th width="10%">是否失联</th>
							<th width="5%">状态</th>
							<th width="10%">创建时间</th>
							<th width="10%">发布人</th>
							<th width="10%">发布人电话</th>
							<th width="10%">操作</th>
						</tr>
						</thead>
						<!--内容-->
						<tbody>
						<volist name="list" id="vo">
							<tr>
								<td>
									<!-- <input type="checkbox" name="id[]" value="{$vo['id']}"/> -->
									{$vo.id}
								</td>
								<td>{$vo.name}</td>
								<td>{$vo.idcardno}</td>
								<td>{$vo.tel}</td>
								<td>
									<if condition="$vo['online'] eq 0">
										已失联
										<elseif condition="$vo['online'] eq 1"/>
										未失联
									</if>
								</td>
								<td>
									<if condition="$vo['status'] eq 0">
										待审核
										<elseif condition="$vo['status'] eq 1"/>
										已发布
										<elseif condition="$vo['status'] eq 4"/>
										已撤销
									</if>
								</td>
								<td>{$vo.year}-{$vo.datestr}</td>
								<td>{$vo.uname}</td>
								<td>{$vo.utel}</td>
								<td>
									<a class="editju" title="查看修改" jid="{$vo.id}"><img src="__WEBPUBLIC__/Admin/images/icons/pencil.png" alt="edit" /></a>

									<a class="delju" title="删除" jid="{$vo.id}"><img src="__WEBPUBLIC__/Admin/images/icons/cross.png" alt="Delete" /></a>
								</td>
							</tr>
						</volist>
						<!--表尾-->
						</tbody>
						<tfoot>
						<tr>
							<td colspan="20">
								<!-- <div class="bulk-actions align-left">
									<input type="submit" value="批量删除" class="button"/>
								</div> -->
								<div class="pagination">
									{$page}
								</div>
								<div class="clear"></div>
							</td>
						</tr>
						</tfoot>
					</table>
				</form>
			</div>
		</div>
	</div>
</div>
<div id="showjubao" style="text-align:center;display:none;height:400px;overflow-y:scroll;">
		<div class="weui-cells mat0 uinput ">
            <div class="weui-cell">
                <div class="weui-cell__hd">姓名</div>
                <div class="weui-cell__bd">
                    <input type="text" name="name" class="weui-input name" placeholder="输入欠款人姓名">
                </div>

            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">身份证号</div>
                <div class="weui-cell__bd">
                    <input type="text" name="idcardno" class="weui-input idcardno" placeholder="输入欠款人身份证号">
                </div>

            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">手机号码</div>
                <div class="weui-cell__bd">
                    <input type="tel" name="tel" class="weui-input tel" placeholder="输入欠款人手机号码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">是否失联</div>
                <div class="weui-cell__bd">
                    <label>
                        <input class="online" type="radio" name="online" value="1">
                        未失联
                    </label>
                    <label>
                        <input class="online" type="radio" name="online" value="0" checked>
                        已失联
                    </label>

                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">现居住地</div>
                <div class="weui-cell__bd">
                    <input type="text" name="area" class="weui-input area" placeholder="输入欠款人居住地">
                </div>
            </div>
        </div>

        <div class="pad10 colbbb">失信记录</div>
        <div class="weui-cells mat0 uinput">
            <div class="weui-cell">
                <div class="weui-cell__hd">欠款总额</div>
                <div class="weui-cell__bd">
                    <input type="text" name="money" class="weui-input money" placeholder="输入欠款数(元)">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">借款日期</div>
                <div class="weui-cell__bd">
                    <input type="date" name="ctime" class="weui-input ctime" placeholder="输入欠款人日期">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">到期日期</div>
                <div class="weui-cell__bd">
                    <input type="date" name="etime" class="weui-input etime" placeholder="输入到期日期">
                </div>
            </div>
        </div>

        <div class="pad10 colbbb">欠款凭据(请上传真实有效的借款凭据)</div>
        <div class="weui-cells mat0 uinput">
            <div class="weui-uploader__bd pad10">
                <ul class="weui-uploader__files" id="uploaderFiles">
                    <!--<li class="weui-uploader__file weui-uploader__file_status">
		                <img class="pic"/>
		            </li>-->
                </ul>
                <!--<div class="weui-uploader__input-box">
                    <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple />
                </div>-->
            </div>
        </div>

        <div class="pad10 colbbb">其他描述(选填)</div>
        <div class="weui-cells weui-cells_form mat0">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <textarea class="weui-textarea remark" placeholder="输入借款情况描述" rows="3" name="remark"></textarea>
                </div>
            </div>
        </div>

        <div class="pad10 colbbb">主要联系人信息(审核属实后，曝光信息将短信通知亲友，有效提高催收效果)</div>
        <div class="weui-cells mat0 uinput ">
            <div class="weui-cell">
                <div class="weui-cell__hd">姓名</div>
                <div class="weui-cell__bd">
                    <input type="text" name="llname" class="weui-input llname" placeholder="输入亲友姓名">
                </div>

            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">关系</div>
                <div class="weui-cell__bd">
                    <input type="text" name="llrelation" class="weui-input relation" placeholder="输入亲友关系">
                </div>

            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">手机号码</div>
                <div class="weui-cell__bd">
                    <input type="text" name="lltel" class="weui-input lltel" placeholder="输入手机号码">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">联系地址</div>
                <div class="weui-cell__bd">
                    <input type="text" name="lladdress" class="weui-input address" placeholder="输入主要联系人的联系地址">
                </div>
            </div>
        </div>
        <div class="weui-btn-area">
            <a class="weui-btn col00f bgfff playdo">撤销</a>
        </div>
        <div class="weui-btn-area">
            <a class="weui-btn bg00f" id="showTooltips">发布</a>
        </div>
</div>
</body>

<script type="text/javascript" src="__WEBPUBLIC__/Admin/js/layer/layer.js"></script>
<script type="text/javascript">
var jid;
$(".editju").on('click',function () {
	jid = $(this).attr("jid");
	$.ajax({
		url:"{:U('Jubao/findJubao')}",
		data:{id:jid},
		dataType:"json",
		type:"post",
		success:function (res) {
			console.log(res);

			if (res.flag == "success") {
				var dataobj = res.data;
				for( var index in dataobj ){
					$("."+index).val(dataobj[index]);
				}
				pic = dataobj['pic'];
				//$(".pic").attr({"pic":dataobj["pic"]});
				$("#uploaderFiles").html("");
				for (var i in pic ) {
					var picstr = pic[i]['pic'];
					var str = '<li class="weui-uploader__file">'
					                +'<img class="pic" src="'+ picstr +'"/>'
					            +'</li>';
					$("#uploaderFiles").append(str);
				}
				layer.open({
					type:1,
					title:"操作",
					content: $('#showjubao'),
					area:["400px","auto"]
				});
			}else{
				layer.msg(res.message);
			}
		}
	})
	
});

$(".delju").on('click',function () {
	var id = $(this).attr("jid");
	if (confirm("您确定要删除？")) {}
	$.ajax({
		url:"{:U('Jubao/delju')}",
		data:{id:id},
		dataType:"json",
		type:"post",
		success:function (res) {
			layer.msg(res.message);
			if (res.flag == "success") {
				setTimeout(function () {
					location.reload();
				},500);
			}
		}
	})
});

$(".playdo").on('click',function () {
	if (confirm("您确定要撤销吗？")) {
		$.ajax({
			url:"{:U('Jubao/playdo')}",
			data:{id:jid},
			dataType:"json",
			type:"post",
			success:function (res) {
				layer.msg(res.message);
				if (res.flag == "success") {
					setTimeout(function () {
						location.reload();
					},500);
				}
			}
		});
	}
	
});


var pic = "";
$("#showTooltips").on('click',function () {
	var name = $(".name").val();
	var idcardno = $(".idcardno").val();
	var tel = $(".tel").val();
	var online = $(".online:checked").val();
	var area = $(".area").val();
	var money = $(".money").val();
	var ctime = $(".ctime").val();
	var etime = $(".etime").val();
	var remark = $(".remark").val();
	var llname = $(".llname").val();
	var llrelation = $(".relation").val();
	var lltel = $(".lltel").val();
	var lladdress = $(".address").val();
	console.log( name , idcardno , tel , online , area , money , ctime , etime );

	if ( name && idcardno && tel && area && money && ctime && etime) {
		console.log("hello");
		var dataobj ={
			id: jid,
			name : name,
			idcardno : idcardno,
			tel : tel,
			online : online,
			area : area,
			money : money,
			ctime : ctime,
			etime : etime,
			remark : remark,
			llname : llname,
			llrelation : llrelation,
			lltel : lltel,
			lladdress : lladdress,
			pic : pic,
			status : 1
		};
		//数据请求
		$.ajax({
			url:"{:U('Jubao/updjinfo')}",
			data:dataobj,
			dataType:"json",
			type:"post",
			success:function ( res ) {
	            if ( res.flag == "success") {
	                console.log( res );
	                window.location.reload();
	            }else{
	                layer.msg( res.message );
	            }
	        }
    	});
	}else{
		console.log("world");
		layer.msg("数据填写不完整！");
		console.log(name, idcardno, tel, online, area, money, ctime, etime, remark, llname, llrelation, lltel, lladdress);
	}
});


function ajax(){
	var filesize = this.files[0].size;
	if (filesize > 5*1024*1024) {
		alert("请上传大小在500k以下的图片");
		return false;
	};
	var self = $(this);
	var files = this.files;
	var picname = files[0].name;
	var reader = new FileReader();
	reader.onload = function(e){
		var src = e.target.result;
		$.ajax({
            type:"post",
            url:"{:U('Home/Jubao/uploadPic')}",
            data: {"pic":src,"pic_name":picname},
            dataType : "json",
            success : function(res){
            	if (res.flag == "success") {
            		pic =res.data;
            		console.log(pic);
            		$("#uploaderFiles").html('<li class="weui-uploader__file weui-uploader__file_status" style="background-image:url('+pic+')">'
	                        +'<div class="weui-uploader__file-content">'
	                        +'</div>'
	                    +'</li>');
            	}else{
            		alert(res.message);
            	}
            }
        });
	}
	reader.readAsDataURL(files[0]);
}
$("input[type='file']").on('change',ajax);
</script>
</html>
